package com.hxzy.service.impl;

import com.hxzy.entity.UmsGrowthChangeHistory;
import com.hxzy.mapper.UmsGrowthChangeHistoryMapper;
import com.hxzy.service.UmsGrowthChangeHistoryService;
import com.hxzy.util.MybatisUtil;
import org.apache.ibatis.session.SqlSession;

public class UmsGrowthChangeHistoryServiceImpl implements UmsGrowthChangeHistoryService {
    @Override
    public UmsGrowthChangeHistory selectByPrimaryKey(Long id) {
        UmsGrowthChangeHistory umsGrowthChangeHistory=null;
        try (SqlSession session= MybatisUtil.getSqlSessionFactory().openSession()){
            UmsGrowthChangeHistoryMapper mapper = session.getMapper(UmsGrowthChangeHistoryMapper.class);
            umsGrowthChangeHistory= mapper.selectByPrimaryKey(id);
        }
        return umsGrowthChangeHistory;
    }

    @Override
    public boolean insert(UmsGrowthChangeHistory record) {
        int count=0;
        try (SqlSession session= MybatisUtil.getSqlSessionFactory().openSession()) {
            UmsGrowthChangeHistoryMapper mapper = session.getMapper(UmsGrowthChangeHistoryMapper.class);
            count=mapper.insert(record);
        }
        return count>0;
    }

    @Override
    public boolean updateByPrimaryKey(UmsGrowthChangeHistory record) {
        int count=0;
        try (SqlSession session= MybatisUtil.getSqlSessionFactory().openSession()) {
            UmsGrowthChangeHistoryMapper mapper = session.getMapper(UmsGrowthChangeHistoryMapper.class);
            count=mapper.updateByPrimaryKey(record);
        }
        return count>0;
    }
}
